home *** CD-ROM | disk | FTP | other *** search
- // Gmail Manager
- // By Todd Long <longfocus@gmail.com>
- // http://www.longfocus.com/firefox/gmanager/
-
- const GM_CC = Components.classes;
- const GM_CI = Components.interfaces;
-
- function gmPrefs() {}
- gmPrefs.prototype = {
- _node: null,
- _temp: null,
- _nodeList: null,
- _prefs: null,
-
- get node() { return this._node; },
- get temp() { return this._temp; },
- get nodeList() { return this._nodeList; },
-
- set node(aNode)
- {
- this._node = aNode;
- this._temp = this._node.cloneNode(true);
- this._nodeList = this._temp.getElementsByTagName("pref");
- this._prefs = new Array();
-
- for (var i = 0; i < this._nodeList.length; i++)
- {
- var pref = new Object();
- var item = this._nodeList.item(i);
-
- pref.id = item.getAttribute("id");
- pref.type = item.getAttribute("type");
- pref.value = item.getAttribute("value");
-
- this._prefs[pref.id] = pref;
- }
- },
-
- load: function()
- {
- this._temp = this._node.cloneNode(true);
- this._nodeList = this._temp.getElementsByTagName("pref");
- },
-
- save: function()
- {
- this.node = this._temp;
- },
-
- getValue: function(aId)
- {
- return this._prefs[aId].value;
- },
-
- getBoolValue: function(aId)
- {
- return (this.getValue(aId) == "true" ? true : false);
- },
-
- getIntValue: function(aId)
- {
- return parseInt(this.getValue(aId));
- },
-
- QueryInterface: function(iid)
- {
- if (!iid.equals(GM_CI.gmIPrefs) &&
- !iid.equals(GM_CI.nsISupports))
- throw Components.results.NS_ERROR_NO_INTERFACE;
- return this;
- }
- }
-
- var myModule = {
- firstTime: true,
-
- myCID: Components.ID("{b1830600-015a-11db-92e3-0800200c9a66}"),
- myDesc: "Service for preferences",
- myProgID: "@longfocus.com/gmanager/prefs;1",
- myFactory: {
- createInstance: function (outer, iid) {
- if (outer != null)
- throw Components.results.NS_ERROR_NO_AGGREGATION;
-
- return (new gmPrefs()).QueryInterface(iid);
- }
- },
-
- registerSelf: function (compMgr, fileSpec, location, type)
- {
- if (this.firstTime) {
- this.firstTime = false;
- throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
- }
-
- compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
- compMgr.registerFactoryLocation(this.myCID, this.myDesc, this.myProgID, fileSpec, location, type);
- },
-
- getClassObject: function (compMgr, cid, iid)
- {
- if (!cid.equals(this.myCID))
- throw Components.results.NS_ERROR_NO_INTERFACE;
-
- if (!iid.equals(Components.interfaces.nsIFactory))
- throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-
- return this.myFactory;
- },
-
- canUnload: function(compMgr) { return true; }
- };
-
- function NSGetModule(compMgr, fileSpec) { return myModule; }